package com.example.demo.config;
/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 */

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AlipayConfig {
    // 支付宝网关
    @Value("${alipay.gateway_url}")
    private String gatewayUrl;
    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    @Value("${alipay.app_id}")
    private String appId;
    // 商户私钥，您的PKCS8格式RSA2私钥
    @Value("${alipay.merchant_private_key}")
    private String merchantPrivateKey;
    // 支付宝公钥
    @Value("${alipay.alipay_public_key}")
    private String alipayPublicKey;
    // 签名方式
    @Value("${alipay.sign_type}")
    private String signType;
    // 服务器异步通知页面路径
    @Value("${alipay.notify_url}")
    private String notifyUrl;
    // 页面跳转同步通知页面路径
    @Value("${alipay.return_url}")
    private String returnUrl;
    @Value("${alipay.uid}")
    private String sellerId;

    public String getGatewayUrl() {
        return gatewayUrl;
    }

    public String getAppId() {
        return appId;
    }

    public String getMerchantPrivateKey() {
        return merchantPrivateKey;
    }

    public String getAlipayPublicKey() {
        return alipayPublicKey;
    }

    public String getSignType() {
        return signType;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public String getReturnUrl() {
        return returnUrl;
    }

    public String getSellerId() {
        return sellerId;
    }
    @Bean
    AlipayClient alipayClient(){
        return new DefaultAlipayClient
                (gatewayUrl,appId,merchantPrivateKey,"json","utf-8",alipayPublicKey,signType);
    }
}

